package com.xiaobawang.knowledge.spider.controller;

import com.xiaobawang.knowledge.spider.service.PingAnProductService;
import com.xiaobawang.knowledge.spider.service.SchedulerService;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author synhard
 * @description 手动触发定时任务
 * @date 2025/3/28 14:44
 * @email songxinhang2023@e-chinalife.com
 * @id 18101119
 * @phone 13001321080
 */
@RestController
@RequestMapping("scheduler")
public class SchedulerController {

    final SchedulerService schedulerService;

    final PingAnProductService pingAnProductService;

    final ResourceLoader resourceLoader;

    public SchedulerController(SchedulerService schedulerService,
                               PingAnProductService pingAnProductService,
                               ResourceLoader resourceLoader) {
        this.schedulerService = schedulerService;
        this.pingAnProductService = pingAnProductService;
        this.resourceLoader = resourceLoader;
    }

    /**
     * @author synhard
     * @description 从官网获取中国人寿产品信息 https://www.e-chinalife.com/xxpl/gsgk/cpjbxx/
     * @date 2025/3/28 15:13
     * @param
     */
    @GetMapping("getChinalifeProductFromWeb")
    public void getChinalifeProductFromWeb(@RequestParam(name = "saleType") Integer saleType,
                                           @RequestParam(name = "fileType") Integer fileType) {
        this.schedulerService.getChinalifeProductFromWeb(saleType, fileType);
    }

    /**
     * @author synhard
     * @description 从官网获取中国平安产品信息 https://life.pingan.com/gongkaixinxipilu/baoxianchanpinmulujitiaokuan.jsp
     * @date 2025/3/28 15:13
     * @param
     */
    @GetMapping("getPingAnProductFromWeb")
    public void getPingAnProductFromWeb() {
        this.pingAnProductService.crawl();
    }

    /**
     * @author synhard
     * @description 获取金融监管总局文件
     * @date 2025/6/9 09:31
     * @param
     */
    @GetMapping("getGovernmentFinancialFile")
    public void getGovernmentFinancialFile() {
        this.schedulerService.getGovernmentRulesFromWeb();
        this.schedulerService.getGovernmentAdministrationFromWeb();
        this.schedulerService.getGovernmentOtherFromWeb();
    }

    /**
     * @author synhard
     * @description 获取人民银行文件
     * @date 2025/4/1 08:56
     * @param
     */
    @GetMapping("getPeopleBankFileFromWeb")
    public void getPeopleBankFileFromWeb() {
        this.schedulerService.getPeopleBankRulesFromWeb();
        this.schedulerService.getPeopleAdministrationFromWeb();
    }

    /**
     * @author synhard
     * @description 获取国家金融监督管理总局政府规章信息 https://www.nfra.gov.cn/cn/view/pages/zhengwuxinxi/zhengfuxinxi.html?signIndex=4#1
     * @date 2025/3/31 16:11
     * @param
     */
    @GetMapping("getGovernmentFinancialRulesFromWeb")
    public void getGovernmentRulesFromWeb() {
        this.schedulerService.getGovernmentRulesFromWeb();
    }

    /**
     * @author synhard
     * @description 获取国家金融监督管理总局政府行政规范性文件 https://www.nfra.gov.cn/cn/view/pages/zhengwuxinxi/zhengfuxinxi.html?signIndex=4#1
     * @date 2025/4/1 08:56
     * @param
     */
    @GetMapping("getGovernmentFinancialAdministrationFromWeb")
    public void getGovernmentAdministrationFromWeb() {
        this.schedulerService.getGovernmentAdministrationFromWeb();
    }

    /**
     * @author synhard
     * @description 获取国家金融监督管理总局其他文件 https://www.nfra.gov.cn/cn/view/pages/zhengwuxinxi/zhengfuxinxi.html?signIndex=4#1
     * @date 2025/4/1 08:56
     * @param
     */
    @GetMapping("getGovernmentFinancialOtherFromWeb")
    public void getGovernmentOtherFromWeb() {
        this.schedulerService.getGovernmentOtherFromWeb();
    }

    /**
     * @author synhard
     * @description 获取国家医疗管理总局其他文件
     * @date 2025/4/1 13:39
     * @param
     */
    @GetMapping("getGovernmentMedicalRulesFromWeb")
    public void getGovernmentMedicalRulesFromWeb() {
        this.schedulerService.getGovernmentMedicalRulesFromWeb();
    }

    /**
     * @author synhard
     * @description 获取人民银行规章 http://www.pbc.gov.cn/zhengwugongkai/4081330/4406346/4406348/index.html
     * @date 2025/4/1 08:56
     * @param
     */
    @GetMapping("getPeopleBankRulesFromWeb")
    public void getPeopleBankRulesFromWeb() {
        this.schedulerService.getPeopleBankRulesFromWeb();
    }

    /**
     * @author synhard
     * @description 获取人民银行行政规范性文件 http://www.pbc.gov.cn/zhengwugongkai/4081330/4406346/4693545/index.html
     * @date 2025/4/1 08:56
     * @param
     */
    @GetMapping("getPeopleAdministrationFromWeb")
    public void getPeopleAdministrationFromWeb() {
        this.schedulerService.getPeopleAdministrationFromWeb();
    }
}
